<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./prism.css" />
    <style>
      .show-data {
        border: red solid 1px;
        min-height: 200px;
        margin-top: 10px;
        padding: 20px;
      }
    </style>
  </head>
  <body>
    <div>当前模式：<span class="packaged"></span></div>
    <button class="one">从主进程-获取环境变量</button>
    <button class="two">通过Exec-获取环境变量</button>
    <div class="show">
      <pre><code class="language-javascript"></code></pre>
    </div>

    <a href="./index.html">去看看主程序执行Exec获取到的系统变量页面</a>

    <script src="./prism.js"></script>
    <script>
      const oneBtn= document.querySelector(".one");
      oneBtn.onclick = async () => {
        const codeEl = document.querySelector("code");
        const process = await $electron.getProcess();
        const jsonObject = JSON.parse(process).env;
        const formattedJson = JSON.stringify(jsonObject, null, "\t");
        console.log(formattedJson);

        codeEl.innerHTML = formattedJson;
        Prism.highlightAll();
      };

      const twoBtn= document.querySelector(".two");
      twoBtn.onclick = async () => {
        const codeEl = document.querySelector("code");
        const env = await $electron.getProcessByExec();
        codeEl.innerHTML = env;
        Prism.highlightAll();
      };

      $electron.isPackaged().then(res=>{
        const packagedEl = document.querySelector('.packaged');
        packagedEl.innerHTML = res?'packaged':'dev';
      })
    </script>
  </body>
</html>
